﻿Chenxin.UI.IncomeSummeryLeader = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: '/service/logic/SalePaymentsBalance.ashx',
    createSearch: function() {
        return new Chenxin.UI.IncomeSummeryLeaderSearch({
            scope: this
        });
    },
	showDetails:function(record){
		if(!this.detailsWin){
			this.detailsWin=new Chenxin.UI.IncomeSummeryLeaderWin({
				id:'x_details_win',
				actionUrl:this.actionUrl+'?op=getdtailslist'
			});
		}
		this.detailsWin.show();
		var title='';
		title+='详情';
		
		this.detailsWin.setTitle(title);
		this.detailsWin.grid.reload();
	},
	initEvent:function(){
		var _this=this;
		$('.btn_viewdetails').live('click',function(){
			_this.showDetails(_this.grid.store.rows[_this.grid.store.map[this.parentNode.parentNode.id].index]);
		});
	},
    createGrid:function(){
        return new Chenxin.UI.JsonGrid({
            actionUrl: this.actionUrl + '?op=search',
            pageSize: 10,
            renderTo: 'divShowBalanceList',
            hasCheckBox: false,
            autoLoad: false,
            scope: this,
            id: 'BalanceList',
			modelId:'a',
            title: '店长级以上实收',
            scope: this,
            columns: {
				a:{head:'员工编号',width:100,sortable:true},
				b:{head:'员工姓名',width:100,sortable:true},
				c:{head:'所在商圈',width:100,sortable:true},
				d:{head:'所在门店',width:100,sortable:true},
				e:{head:'个人实收',width:100,sortable:true},
				f:{head:'业绩归属',width:100,sortable:true},
				g:{
					head:'操作',
					width:100,
					renderer:function(val,c,row){
						return '<a title="查看详细" class="btn_viewdetails" r="'+row.a+'" style="cursor:pointer">查看详细</a>';
					}
				}
            }
        });
    },
	initComponent:function(){
		Chenxin.UI.IncomeSummeryLeader.superclass.initComponent.call(this);
	}
});


Chenxin.UI.IncomeSummeryLeaderWin=Chenxin.extend(Chenxin.UI.Win,{	
	id:'',
	actionUrl:'',
	width:680,
	hasFoot:true,
	height:360,
	content:'<div id="x_details_grid"></div>',
	createBtn:function(){
		return [{
			text:'关闭',
			handler:this.hide
		}]	
	},
	createGrid:function(){
		if(this.grid){
			return;
		}
        this.grid=new Chenxin.UI.JsonGrid({
			autoLoad:false,
			actionUrl:this.actionUrl,
            id: 'x_details_grid',
            renderTo: 'x_details_grid',
            hasCheckBox: false,
            modelId: 'a',
            scope: this,
			height:311,
			hasTitle:false,
			columns:{
				a:{head:'商圈',width:100,sortable:true},
				b:{head:'门店',width:100,sortable:true},
				c:{head:'成交编号',width:100,sortable:true},
				d:{head:'成交日期',width:100,sortable:true},
				e:{head:'区域',width:100,sortable:true},
				f:{head:'房屋地址',width:100,sortable:true},
				g:{head:'业务员',width:100,sortable:true},
				h:{head:'店长',width:100,sortable:true},
				i:{head:'高级经理',width:100,sortable:true},
				j:{head:'总监',width:100,sortable:true},
				k:{head:'应收佣收',width:100,sortable:true},
				l:{head:'折佣',width:100,sortable:true},
				m:{head:'咨询费',width:100,sortable:true},
				n:{head:'业绩',width:100,sortable:true},
				o:{head:'点数',width:100,sortable:true},
				p:{head:'分摊应收',width:100,sortable:true},
				q:{head:'分摊咨询费',width:100,sortable:true},
				r:{head:'分摊业绩',width:100,sortable:true},
				s:{head:'实收',width:100,sortable:true},
				t:{head:'分摊实收',width:100,sortable:true},
				u:{head:'业绩归属日期',width:100,sortable:true},
				v:{head:'合同归属公司',width:100,sortable:true}
			}
		});
	},
	initComponent:function(){
		Chenxin.UI.IncomeSummeryLeaderWin.superclass.initComponent.call(this);
		this.createGrid();
	}
});

/*
* 查询面板
*/
Chenxin.UI.IncomeSummeryLeaderSearch = Chenxin.extend(Chenxin.UI.SearchCommon, {
    id: 'divCondition',
    createComboList: function() {
		var _this=this;		
        //人员
        this.comboUserId = new Chenxin.UI.RichModelTreeCombo({
            textBoxId: 'txtUser',
            inModelType: 'all',
            txtModelName: 'UserName',
            singleSelect: true,
            name: 'UserId'
        });
		
        this.combl = new Chenxin.UI.StructComboList({
            tbxWidth: 110,
            cityAfterSelected: function() {
                _this.comboUserId.reset();
            },
            companyAfterSelected: function() {
                _this.comboUserId.reset();
            },
            businessDistrictAfterSelected: function() {
                _this.comboUserId.reset();
            },
            departsAfterSelected: function(val) {
                _this.comboUserId.reset();
                if (val != '请选择') {
                    _this.comboUserId.loadUser(val, 500);
                }
            }
        });
		
        //收支情况
        var LevelType = new Chenxin.UI.Combo({
            containerId: '#LevelType',
            tbxWidth: 110,
            items: [{val:'10',txt:'店长'},{val:'10',txt:'高经'},{val:'30',txt:'总监'}]
        });
		
        var structs = this.combl.comboList;
        structs.push(this.comboUserId);
        structs.push(LevelType);
        return this.combl.comboList;
    },
    initEvent: function() {
        $(".x_date").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM-dd',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        })
		
        var objSrh = this;
        /*********事件：检索按钮*********/
        $("#btSearch").click(function() {
            objSrh.scope.reloadGrid();
        });
    }
});

getcity = true; //设置需要获取城市下拉框数据

$(function() {
    var objPg = new Chenxin.UI.IncomeSummeryLeader();
});